{extend name="common/form" /}
{block name="form" /}

<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
    <div class="widget am-cf">
        <div class="widget-head am-cf">
            <div class="widget-title am-fl">{:urldecode($Request.param.name)}：价格明细</div>
            <div class="widget-function am-fr">
                <a href="javascript:;" class="am-icon-cog"></a>
            </div>
        </div>
        <form >
            <button type="button" onclick="add('{:url("")}','form')" class="am-btn am-btn-xs am-btn-default am-btn-success"><span class="am-icon-search"></span> 保存</button>

            <div class="widget-body  widget-body-lg am-fr">
                <table width="100%" class="am-table am-table-compact am-table-bordered tpl-table-black ">
                    <thead>
                    <tr>
                        <th class="am-lg-text-center">
                            区域名
                        </th>
                        <th class="am-lg-text-center" style="position: relative">
                            价格
                            {eq name="ADMINTYPE" value="1"}
                            <div style="position: absolute;right: 10px;top: 1px;">
                                <input class="inp" id="price" value="{$reference_price}" style="width: 60px;display: none;">
                                <button type="button" class="am-btn am-btn-warning am-btn-xs show_inp" >批量修改</button>
                                <button type="button" class="inp am-btn am-btn-success am-btn-xs " onclick="shePrice()" style="display: none">确定</button>
                                <button type="button" class="inp am-btn am-btn-danger am-btn-xs " onclick="none(this)" style="display: none">取消</button>
                            </div>
                            {/eq}

                        </th>
                    </tr>
                    </thead>
                    {foreach $list as $v}
                    <tr class="gradeX">
                        <td class='am-lg-text-center'> {$v.name}</td>
                        <td class="am-lg-text-center">
                            <input type="text" style="width: 70px"  name="{$Request.param.type_id}_{$v.region_id}" value="{$v.price|default='0.00'}" placeholder="">
                        </td>
                    </tr>
                    {/foreach}
                </table>
            </div>

        </form>
    </div>
</div>
<script type="text/javascript">
    function add(url,form) {
        $.post(url,$(form).serialize(),function (res) {
            if(res.code!=0){
                layer.alert(res.msg,{icon:5})
            }else{
                layer.alert('操作成功!',{icon:6},function () {
                    var index = parent.layer.getFrameIndex(window.name);
                    window.parent.location.reload();
                    parent.layer.close(index);//关闭当前页

                })
            }
        },'json')
    }

</script>
{/block}
{block name="script"}
<script type="text/javascript">
    $('.show_inp').click(function () {
        $('.inp').show();
        $(this).hide()
    });
    function none(e) {
        $('.show_inp').show();
        $('.inp').hide()
    }
    function shePrice() {
        var price = $('#price').val();
        $('input').val(price);
    }
</script>
{/block}
{/extend}